#include "gtest/gtest.h"
#include "../BaseUtil/MyTest.h"
#include "PANEImp.h"
namespace PANEImp {

class PANEImageElementTest : public testing::Test {
protected:
    virtual void SetUp() {
    	doc = new PANEDocument();
    	img = doc->createPANEImageElement();
    }
    virtual void TearDown() {
    	delete doc;
    }

    PANEDocument * doc;
    PANEImageElement * img;
};

TEST_F(PANEImageElementTest, LoadAndRenderImage) {
	img->setSrc( "../VoodooData/car000.jpeg" );
	img->loadURL();
	ASSERT_TRUE( img->getIsLoaded() );

	const unsigned long width = img->getWidth();
	const unsigned long height = img->getHeight();
	ASSERT_EQ(640ul, width);
	ASSERT_EQ(480ul, height);

    IplImage * output = cvCreateImage( cvSize(width, height), IPL_DEPTH_8U, 3 );
    ASSERT_FALSE( *(output->imageData) );
	img->render( output );
    ASSERT_TRUE( *(output->imageData) );
	cvReleaseImage( &output );
}

}
